package com.yowasa.xiuxian.entity.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum ItemTypeEnum {
    DAN_YAO(1, "食物"),
    LING_YAO(2, "灵药"),
    WU_QI(3, "装备"),
    MI_JI(4, "秘籍"),
    SU_CAI(5, "素材"),
    TU_ZHI(6,"图纸")

    ;
    //类型编号
    private int id;
    //名称
    private String name;


    public static ItemTypeEnum getById(int id) {
        return Arrays.stream(ItemTypeEnum.values()).filter(e -> e.getId() == id).findFirst().orElse(null);
    }

    public static ItemTypeEnum getByName(String name) {
        return Arrays.stream(ItemTypeEnum.values()).filter(e -> e.getName().equals(name)).findFirst().orElse(null);
    }
}
